<%@ page contentType="text/html; charset=utf-8" language="java"  errorPage="" %>
<%@ page import="com.netscenery.yang.model.Extension" %>
<%@ page import="com.netscenery.yang.model.Env" %>
<%@ page import="operate.OperateType"%>
<%@page import="offer.GetDataSource"%>
<%@page import="offer.SessionObj"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
Extension extension = new Extension(new Env(),"MyExtension");
//获取结点对象
Object itemNode = request.getAttribute("itemNode");
Object opType   = request.getAttribute("opType"); //获取操作对象
if( null != itemNode){
	extension = (Extension)itemNode;
}
SessionObj sessionObj = (SessionObj)request.getSession().getAttribute("sessionObj");
String control_disabled = "";
if(!sessionObj.getModuleStatus().toString().equalsIgnoreCase("EDITING")){
 control_disabled ="disabled='disabled'";
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Extension</title>
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Cache-Control" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>/css/items.css" />
    <script type="text/javascript"  src="<%=basePath%>jstree-v.pre1.0/_lib/jquery.js"></script>
    <script type="text/javascript"  src="<%=basePath%>js/StringUtil.js"></script>
</head>

<body class="body">
<script type="text/javascript">
   function bodyLoad(){
   <% if( (null != itemNode) 
        &&  (!opType.toString().equalsIgnoreCase(OperateType.LOAD))){ %>
  <%   		 if(opType.toString().equalsIgnoreCase(OperateType.ADD)|| 
  				opType.toString().equalsIgnoreCase(OperateType.MODIFY_INCLUDE_NAME)){ %>
	   		 	 //新增节点时，重新加载数
	   		 	 parent.reloadTreeWithNode(document.getElementById("nodeId").value);
  <%   	} %>
			 $("#opNoticeSpan").html("操作成功！");
   		 	 setTimeout(function(){$("#opNoticeSpan").html("")},3000);
   <% }%>  
   }
   $(document).ready(function(){
   		$("#submitButton").click(function(){
	 	     $(":input").css("border-color","");
		     if($("#name").val().trim().length == 0){
		        $("#name").css("border-color","red");
		        alert("name 不能为空！");
		        return;
		     }
		     //名字验证
		     if(!nameVerify($("#name").val().trim(),$("#name"))){
		     	 return;
		     }
		    document.getElementById("ExtensionForm").submit(); 
		});
	    bodyLoad();
   })
</script>
 <form id="ExtensionForm" method="post" action="<%=basePath %>ExtensionOpreateServlet" class="IndexFormStyle" >
   <input type="hidden"  id="nodeId" name="nodeId" value="<%=request.getAttribute("nodeId") %>"  />
   <div id="TableContent" class="tableContent" >
   <table border="0" class="mainTable" >
     <tr>
       <td colspan="2"  class="titleTd">
       The Extension [<%=extension.getName() %>] information 
       </td>
     </tr>
     <tr>
       <td>&nbsp;Extension name:</td>
       <td>
          <input class="inputText" id="name" name="name" value="<%=extension.getName()==null?"":extension.getName()%>"  />
       </td>
     </tr>
     <tr>
       <td>&nbsp;Argument:</td>
       <td>
          <input class="inputText" id="argument" name="argument" value="<%=extension.getArgument()==null?extension.getName():extension.getArgument()%>"  />
       </td>
     </tr>
     <tr>
       <td>&nbsp;Status:</td>
       <td>
          <select style="width:305px;   height:23px;"   class="inputSelect" id="_status" name="_status">
          <% for(int i = 0 ; i < GetDataSource.getStatusList().length ; i++ ){ %>
          <%     if(extension.getStatus().getStatus().equalsIgnoreCase(GetDataSource.getStatusList()[i])){ %>  
                    <option  value="<%= GetDataSource.getStatusList()[i]%>" selected="selected"><%=GetDataSource.getStatusList()[i] %></option>
          <%     }else{ %> 
                    <option  value="<%= GetDataSource.getStatusList()[i]%>" ><%=GetDataSource.getStatusList()[i] %></option>   
          <%     }
             } %>
          </select>
       </td>
     </tr>
     <tr>
       <td colspan="2">&nbsp;Description:</td>
     </tr>
     <tr>
       <td colspan="2">
         <textarea class="textArea"  id="description" name="description"><%=extension.getDescription()==null?"":extension.getDescription() %></textarea>
       </td> 
     </tr>
     <tr>
       <td colspan="2">&nbsp;Reference:</td>
     </tr>
     <tr>
       <td colspan="2">
         <textarea class="textArea"  id="reference" name="reference"><%=extension.getReference()==null?"":extension.getReference() %></textarea>
       </td>
     </tr>
   </table>
   </div>
   <div id="submitContent" class="submitContent">
     <span id="opNoticeSpan" style="color:red;" ></span>
     <span class="textSpan">&nbsp;</span>
     <input type="button" <%=control_disabled %> id="submitButton" value="Apply"  />
   </div>
   </form>
</body>
</html>